package com.itgone.view.activity;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.itgone.R;

public abstract class BaseActivity extends AppCompatActivity {


    private TextView mTvTitle;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());

        mTvTitle = findViewById(R.id.tv_activity_title);

        initView();
        initData();
    }

    @Override
    public void setContentView(int layoutResID) {
        LayoutInflater inflater = LayoutInflater.from(this);
        View activityBase = inflater.inflate(R.layout.activity_base, null);
        ViewGroup containerActivity = activityBase.findViewById(R.id.container_activity);

        inflater.inflate(layoutResID, containerActivity);
        super.setContentView(activityBase);
    }

    protected void setTitle(String title) {
        mTvTitle.setText(title);
    }

    abstract @LayoutRes
    int getLayoutId();

    protected abstract void initView();

    ;

    protected abstract void initData();

}
